package com.xxgc.wujiaosocket.job;

import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.stereotype.Component;

/**
 * @Component 给spring进行管理
 * @Slf4j 打印日志
 */

@Slf4j
@Component
public class HelloJob {

    @Autowired
    private SimpMessageSendingOperations messageTemplate;

    @XxlJob("sayHello")
    public void sayHello() {
        log.info("我被任务调度中心调度了");
    }

    @XxlJob("zhubo")
    public void zhubo() {
        log.info("调用成功");
        String message = """
                {"code":0,"nickname":"系统消息","level":1,"avatar":"https://picsum.photos/200/200","content":"给主播点点赞，点点关注"}
                """;

        messageTemplate.convertAndSend("/wujiao/live",message);
    }

}
